package angry.courses.database;

import java.util.List;
import java.util.ArrayList;

public class CoursesDBMock implements ICoursesDB {
    private List<Course> courses;
    private List<Student> students;

    public CoursesDBMock() {
	courses = new ArrayList<Course>();
	addCourse("Distributed Systems", "Jurca", 4, 1);
	addCourse("PLDA", "Minea", 4, 1);
	addCourse("Research", "Marinescu", 4, 1);
	addCourse("PMPE", "Niculescu", 4, 1);
	addCourse("CBS", "Sora", 4, 1);
	addCourse("PR", "Holban", 4, 1);
	addCourse("ADB", "Jian", 4, 2);
	addCourse("DCDA", "Jurca", 4, 2);
	addCourse("FVPA", "Minea", 4, 2);
	addCourse("RTSD", "Cretu", 4, 2);
	addCourse("MLCM", "Crisan", 4, 2);
	addCourse("HM", "Ciocarlie", 4, 2);
	addCourse("ITPM", "Cretu", 4, 2);
	addCourse("Research 2", "?", 4, 2);

	students = new ArrayList<Student>();
	students.add(new Student("Andrei", "65", 4));
	students.add(new Student("Dan", "78", 3));
    }

    public void addCourse(String name, String prof, int year, int sem) {
	courses.add(new Course(name, prof, year, sem));
    }

    public void removeCourse(String name) {
	Course toDelete = null;
	for (Course course : courses) {
	    if (course.name.equals(name)) {
		toDelete = course;
		break;
	    }
	}
	if (toDelete != null) {
	    courses.remove(toDelete);
	}
    }

    public List<String> getCourseNames() {
	List<String> courseNames = new ArrayList<String>();
	for (Course course : courses) {
	    courseNames.add(course.name);
	}
	return courseNames;
    }
    
    public List<String> getCourseNames(int sem) {
	List<String> courseNames = new ArrayList<String>();
	for (Course course : courses) {
	    if (course.sem == sem) {
		courseNames.add(course.name);
	    }
	}
	return courseNames;
    }

    public void register(String name, String regnr, int year,
			 List<String> courses) {
	students.add(new Student(name, regnr, year));
	// TODO: courses
    }

    public void deleteStudent(String name) {
	Student toDelete = null;
	for (Student student : students) {
	    if (student.name.equals(name)) {
		toDelete = student;
		break;
	    }
	}
	students.remove(toDelete);
    }

    public boolean validateStudent(String name, String regnr) {
	for (Student student : students) {
	    if (student.name.equals(name) && student.regnr.equals(regnr)) {
		return true;
	    }
	}
	return false;
    }

	public int getYearOfStudy(String name, String regnr) {
		//not needed here i think
		return 0;
	}

	public void modify(String name, String regnr, int year, List<String> courses) {
		//TODO or not...
	}

	@Override
	public List<String> getCoursesForStudent(String name, int semester) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Student getStudent(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getStudentNames() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Course getCourse(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getStudentsForCourse(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Course> getCourses(int year, int semester) {
		// TODO Auto-generated method stub
		return null;
	}
}
